﻿using Catel.Articles._03___MVVM.Examples.BasicViewModel;
using Catel.Articles._03___MVVM.Models;
using Catel.Articles.Base.Data.Attributes;
using Catel.Windows;

namespace Catel.Articles._03___MVVM.Examples.DataWindow
{
    /// <summary>
    /// Interaction logic for PersonWindow.xaml
    /// </summary>
    [Example("DataWindow", "Example of the DataWindow<TViewModel>",
        LongDescription = @"The DataWindow<TViewModel> serves as the base class for all windows that use the MVVM Framework of Catel.",
        SourceFileName = "/Examples/DataWindow/Code.txt",
        ClickHandlerName = "ShowExample")]
    public partial class PersonWindow : DataWindow<PersonViewModel>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PersonWindow"/> class.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        public PersonWindow(PersonViewModel viewModel)
            : base(viewModel)
        {
            // Initialize component
            InitializeComponent();
        }

        /// <summary>
        /// Shows the example.
        /// </summary>
        private static void ShowExample()
        {
            // Create model
            Person person = new Person();
            person.Gender = Gender.Male;
            //person.FirstName = "Geert";
            //person.MiddleName = "van";
            //person.LastName = "Horrik";

            // Create view model
            PersonViewModel viewModel = new PersonViewModel(person);

            // Show the window
            PersonWindow personWindow = new PersonWindow(viewModel);
            personWindow.ShowDialog();
        }
    }
}